# Definition for singly-linked list.

# class ListNode(object):

# def __init__(self, x):

# self.val = x

# self.next = None

class Solution(object):

def removeNthFromEnd\(self, head, n\):

    lst=\[\]

    while\(head\):

        lst+=\[head.val\]

        head=head.next

    print\(lst\)

    temp=ListNode\(0\)

    result=temp



    i=0

    end=len\(lst\)-1

    while \(i<=end\):

        if \(end-i\)!= n-1:

            value=lst\[i\]

            temp.next=ListNode\(value\)

            temp=temp.next

        i+=1



    return result.next

results matching ""

    No results matching ""